//
//  UIStandardInputTextView.m
//  vhStressTest1
//
//  Created by jia yu on 2021/8/31.
//

#import "UIStandardInputTextView.h"
#import <vhECGTools/vhECGTools.h>

@interface UIStandardInputTextView()<NSLayoutManagerDelegate>{
    float screenRatio;
}

@end

@implementation UIStandardInputTextView
@synthesize style;

-(void)drawRect:(CGRect)rect{
    switch (style) {
        case UIStandardInputTextView_Style_Board:
            self.font = [UIFont fontWithName:@"PingFangSC-Regular" size:34.f * screenRatio];
            self.layer.borderColor = [vhECGTools colorFromHEXString:@"dde0e2"].CGColor;
            break;
        case UIStandardInputTextView_Style_Default:
            self.font = [UIFont fontWithName:@"PingFangSC-Medium" size:34.f * screenRatio];
            self.layer.borderColor = [vhECGTools colorFromHEXString:@"f7fafc"].CGColor;
            break;
        default:
            break;
    }
//    [super drawRect:rect];
}

-(id)initWithFrame:(CGRect)frame{
    NSLog(@"please -(id)initWithFrame:(CGRect)frame scale:(float)scale for it.");
    return nil;
}

-(id)initWithFrame:(CGRect)frame scale:(float)scale{
    self = [super initWithFrame:frame];
    if (self){
        style = UIStandardInputTextView_Style_Default;
        self.font = [UIFont fontWithName:@"PingFangSC-Medium" size:34.f * screenRatio];
        self.backgroundColor = [vhECGTools colorFromHEXString:@"f7fafc"];
        screenRatio = scale;
        self.layer.masksToBounds = YES;
        self.layer.cornerRadius = 16.f * screenRatio;
        self.layer.borderWidth = 2.3f * screenRatio;
        self.textColor = [vhECGTools colorFromHEXString:@"294559"];
        self.textContainerInset = UIEdgeInsetsMake(30.f * screenRatio, 20.f * screenRatio, 50.f * screenRatio, 20.f * screenRatio);
        self.layoutManager.delegate = self;
    }
    return self;
}


#pragma mark - NSLayoutManagerDelegate
- (CGFloat)layoutManager:(NSLayoutManager *)layoutManager lineSpacingAfterGlyphAtIndex:(NSUInteger)glyphIndex withProposedLineFragmentRect:(CGRect)rect{
    //for input line height
    return 20 * screenRatio;
}

@end
